<extend name="template/base_index" />

<block name="area_header">
    <link rel="stylesheet" type="text/css" media="all" href="__CSS__/wxshop.css">
    <link type="text/css" rel="stylesheet" src="__CDN__/jquery-uploadify/3.2.1/uploadify.css" />
    <script type="text/javascript" src="__CDN__/jquery-uploadify/3.2.1/jquery.uploadify.min.js"></script>
    <link type="text/css" rel="stylesheet" href="__CDN__/select2/3.5.2/select2.css" />
    <script type="text/javascript" src="__CDN__/select2/3.5.2/select2.min.js"></script>
    <script type="text/javascript" src="__CDN__/select2/3.5.2/select2_locale_zh-CN.js"></script>
</block>

<block name="area_body">
    {:W('Menus/topbar')}
    <div class="admin-main container-fluid">
        {:W('Menus/left')}
        <div class="admin-main-content">
            {:W('Menus/breadcrumb')}

            <div class="col-main">
                <div class="main-hd">
                    <h2>发表帖子</h2>
                </div>
                <div class="main-bd clearfix">
                    <form class="productForm form-horizontal" method="post">
                        <input type="hidden" name="img" value="" id="img" />
                        <h3><i>●</i>基本信息</h3>

                        <div class="form-group col-lg-12 col-md-12 clearfix ">
                            <label for="" class="control-label col-lg-2 col-md-2 ">版块选择
                                <br/><span class="help-block"></span>
                            </label>
                            <div class="col-lg-10 col-md-10">
                                <select name="fid" class="js_product_group">
                                <volist name="forum" id="vo">
                                    <option  class="forum" value="{$vo.fid}">{$vo.name} <eq name="vo.modnewposts" value="1">[需审]</eq> </option>
                                    <notempty name="vo['child']">
                                    <volist name="vo['child']" id="v">
                                    <option  class="forum" value="{$v.fid}">--{$v.name} <eq name="v.modnewposts" value="1">[需审]</eq> </option>
                                    </volist>
                                    </notempty>
                                </volist>
                                </select>
                            </div>
                        </div>
                        <div class="form-group col-lg-12 col-md-12 clearfix">
                            <label for="" class="control-label col-lg-2 col-md-2">主题帖标题</label>
                            <div class="col-lg-10 col-md-10">
                                <input name="subject" maxlength="60" class="js_subject form-control input-normal input-sm" />
                                <span class="help-block">限40个字</span>
                            </div>
                        </div>

                        <div class="form-group col-lg-12 col-md-12 clearfix">
                            <label for="synopsis" class="control-label col-md-2 col-lg-2 ">主题帖内容</label>
                            <div class="col-md-10 col-lg-10">
                                <textarea name="message" class="form-control" rows="5"></textarea>
                                <div class="help-block">(您最多可以输入500个字)</div>
                            </div>
                        </div>

                        <div class="form-group col-lg-12 col-md-12 clearfix">
                            <label for="" class="control-label col-lg-2 col-md-2">&nbsp;</label>
                            <div class="col-lg-10 col-md-10">
                                图片<span class="text-muted">(选传，单张图片大小不超过500kb，最多10张)</span>
                                <!-- 图片选择DOM结构 -->
                                <div class="wxuploaderimg clearfix product-imglist"  data-maxitems="10">
                                    <div class="img-preview clearfix" >

                                    </div>
                                    <div class="add">
                                        <i class="fa fa-plus"></i>
                                    </div>
                                </div>

                                <!-- 图片选择DOM结构 -->
                            </div>
                        </div>

                        <div class="form-group col-lg-12 col-md-12 clearfix tool-bar text-center border">
                            <a target-form="productForm" href="{:U('Admin/BbsThread/add')}" onclick="return check();"  class="ajax-post btn btn-primary" id="js_submit"><i class="fa fa-check"></i>确定</a>
                        </div>
                    </form>
                </div>
            </div>

            <include file="template/wxpicture" />
        </div>
        <!-- END admin-main-content -->
    </div>
    <!-- END admin-main-->
</block>

<block name="area_footer">
    <script type="text/javascript" src="__JS__/product.js?v=__APP_VERSION__"></script>
    <script type="text/javascript">
        function getData(){
            $("#img").val("");
            $(".product-imglist .img-preview img").each(function(index,item){
                $("#img").val($("#img").val()+$(item).attr("data-imageid")+",");
            });
        }


        function check(){
            getData();
            var txt = $(".js_subject").val();
            var len = txt.replace(/[^\x00-\xff]/g, 'xx').length ;
            if(len == 0){
                $.scojs_message('帖子标题必须填写', $.scojs_message.TYPE_ERROR);
                return false;
            }
            if(len > 40){
                $.scojs_message('帖子标题不能超过40个字', $.scojs_message.TYPE_ERROR);
                return false;
            }
            return true;
        }
        //初始化select2 控件
        // function initSelect2(){
        //     $('select').select2();
        // }

        $(function() {
            //图片上传
            wxuploadimg.init({cont:".wxuploaderimg"});

            // initSelect2();

        })

    </script>

</block>